#include "timer.h"
#include <sdl/sdl.h>

////////////////////////////////////////////////////////////////////////////////

struct TimerState
{
  unsigned old_time;
  unsigned time;
};

static TimerState state;

////////////////////////////////////////////////////////////////////////////////

void Timer_init()
{
  state.old_time = 0;
  state.time = 0;
}

void Timer_sleep(unsigned time)
{
  SDL_Delay(time);
}

void Timer_update()
{
  state.old_time = state.time;
  
  state.time = SDL_GetTicks();
}

unsigned Timer_getDM()
{
  return state.time - state.old_time;
}

float Timer_getDT()
{
  return 0.001f * (state.time - state.old_time);
}
